<script>on searchDestroyFilesglobal usersVolume,sourceFile,destFile,loopCount,error,job,SDCount,¬eraseFolder,buttonNameput "S & D file " & loopcount into buttonNameput "-----Search & Destroy Files" into jobput empty into SDCountif hilite of button buttonName of card "Files Card" is true thenput empty into card field "Found Files" of card 1Get Pathlines(sourceFile,"file")put it into fileNameput "Searching for & deleting old copies of " & fileName into¬cd fld "SourceField"put empty into cd fld "Destfield"put "Please wait..." into cd fld "Misc."get gettype(sourceFile)put it into fileTypeput FindFile(UsersVolume,fileName,fileType) into¬card field "Found Files" of card 1repeat with SDCount = 1 to the number of lines in cd fld¬"Found Files" of card 1put line SDCount of card field "Found Files"¬of cd 1 into fileToDeleteput "Deleting " & filetoDelete into cd fld "Destfield"EraseFile fileToDeleteput the result into errorif error = "Error : Unknown #-45" thenput "File was locked" into errorshowErrorput "Unlocking " & filetoDelete into cd fld "Destfield"setlock fileToDelete,FALSEput the result into errorshowErrorput "Again Deleting " & filetoDelete into cd fld "Destfield"EraseFile fileToDeleteput the result into errorshowErrorelseshowErrorend ifend repeatif SDCount is empty thenput "No copies found..." into cd fld "Destfield"showErrorelseend ifelseend ifset cursor to watchend searchDestroyFileson folderCheck--CREATES FOLDER DURING FILE COPY IF NEEDED--global usersVolume,sourceFile,destFile,loopCount,error,job,¬eraseFolder,buttonNameGet Pathlines(destfile,"folder")put it into folderNameput folderName into temp1delete last char of temp1if temp1 = usersVolume then exit folderCheckput "Creating Folder for file copying:" into cd fld "SourceField"put folderName into cd fld "DestField"put "-----Folder creation subroutine for FILES..." into jobCreateFolder folderNameput the result into errorif error = "Error : Duplicate file/folder name" then put¬"Folder Exists...no need to create new one" into errorshowErrorset cursor to watchend folderCheckon folderCreate--CREATES FOLDER DURING FOLDER COPY IF NEEDED--global usersVolume,sourceFolder,destFolder,error,job,eraseFolder,¬buttonNameGet Pathlines(destfolder,"folder")put it into folderNameput "Creating folder for folder copying:" into cd fld "SourceField"put folderName into cd fld "DestField"put "-----Folder creation subroutine for FOLDERS..." into jobCreateFolder folderNameput the result into errorshowErrorput "From--> " & sourcefolder into cd fld "Sourcefield"put "To --> " & destfolder into cd fld "Destfield"copyFolder sourceFolder,destFolder,trueput the result into errorshowErrorset cursor to watchend folderCreateon extraFileglobal usersVolume,sourceFolder,destFolder,loopCount,erasefolder,¬folderName,error,job,buttonNameif eraseFolder = "Yes" thenput "-----Erasing existing folder on user's drive..." into jobGet Pathlines(sourceFolder,"file")put destFolder & it into fldrtoEraseput empty into cd fld "Sourcefield"put "Erasing " & fldrtoErase into cd fld "Destfield"put "Replacing existing folder..." into cd fld "Misc."removeFolder fldrtoEraseput the result into errorshowErrorput "From --> " & sourcefolder into cd fld "Sourcefield"put "To --> " & destfolder into cd fld "Destfield"put "Now copying new folder onto user's drive..." into cd fld¬"Misc."put "-----Now copying new folder onto user's drive..." into jobcopyFolder sourceFolder,destFolderput the result into errorshowErrorexit extraFileelseput "Folder exists...will copy individual files later." into¬cd fld "Misc."put "-----Copying folder...already exists, will copy files later."¬into jobget the number of lines in cd field¬"Source Extras" of cd "Folders Card"put it into sourceLinesput FindFile(sourceFolder,"") into line (sourceLines+1) of cd fld¬"Source Extras" of card "Folders Card"set cursor to watchrepeat with i = (sourceLines+1) to the number of lines in cd fld¬"Source Extras" of card "Folders Card"get pathlines(sourceFolder,"file")put it into itemIwantget line i of cd fld "Source Extras" of cd "Folders Card"put it into searchstringget offset(itemIwant,searchstring)put it into startput the length of searchstring into endCharput line loopcount of cd fld "Destination Folders" of cd¬"Folders Card" into tempNameput usersVolume & ":" & tempname & char start to endChar¬of searchstring into finalPathget the number of lines of cd fld "Destination Extras"¬of card "Folders Card"put it into destLinesput finalPath into line (destLines+1) of cd fld¬"Destination Extras" of card "Folders Card"end repeatend ifshowerrorend extraFileon copyExtrasget cd fld "Source Extras" of card "Folders Card"if it is empty then exit copyExtras--- MAKE SURE SOURCE & DEST FIELDS HAVE SAME AMT OF FILES ---put "Checking for consistency..." into cd fld "Misc."global usersVolume,sourceFolder,destFolder,loopCount,error,jobput empty into cd fld "Sourcefield"put empty into cd fld "Destfield"put "-----Checking for consistency before copying extras..." into jobrepeat with i = 1 to the number of lines in cd fld¬"Source Extras" of card "Folders Card"end repeatrepeat with j = 1 to the number of lines in cd fld¬"Destination Extras" of card "Folders Card"end repeatif i<>j thenbeep 2put "THERE WAS A FATAL ERROR IN CONSISTENCY CHECK!!!" into jobput "Terminated by an error!!! Some files not copied" into cd¬fld "Misc."put "Error in consistency check." into cd fld "SourceField"put "Extra files not copied." into cd fld "destField"showErrorexit copyExtraselse--COPY THE FILES--put "-----Copying these extra files to user's drive..." into jobrepeat with i = 1 to the number of lines in cd fld¬"Source Extras" of card "Folders Card"if i > 1 then put empty into jobput line i of cd field "Source Extras" of card¬"Folders Card" into sourceFileput line i of cd field "Destination Extras" of card¬"Folders Card" into destFileput "o" into replaceput "From --> " & sourcefile into cd fld "Sourcefield"put "To --> " & destFile into cd fld "Destfield"put "Copying individual files from folders..." into cd fld "Misc."copyFile sourceFile,destFile,replaceput the result into errorshowErrorend repeatend ifend copyExtras</script>